from typing import Tuple

def signature_to_rsv(signature: bytes) -> Tuple[int, int, int]:
    if not isinstance(signature, bytes) or len(signature) != 65:
        raise ValueError('Signature must be 65 bytes long.')
    r = int.from_bytes(signature[0:32], 'big')
    s = int.from_bytes(signature[32:64], 'big')
    v = signature[64] + 27
    return r, s, v

def rsv_to_signature(r: int, s: int, v: int) -> bytes:
    return r.to_bytes(32, 'big') + s.to_bytes(32, 'big') + (v - 27).to_bytes(1, 'big')